home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / un / process.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  1.9 KB  |  69 lines

  1. #include "icmun.h"
  2.  
  3. void process ()
  4. {
  5.     register
  6.         OPCODE_ op;
  7.     register unsigned
  8.         i;
  9.     INT32
  10.         oldoffs;
  11.     static char
  12.         buf [200];
  13.  
  14.     printf ("Binary file statistics:\n"
  15.             "\tstrings           at offset\t%s\n" ,
  16.                 hexstring ( (UNS16) headerp->offset[0], 4 ));
  17.     printf ("\tvariables         at offset\t%s\n",
  18.                 hexstring ( (UNS16) headerp->offset[1], 4 ));
  19.     printf ("\tfilenames         at offset\t%s\n",
  20.                 hexstring ( (UNS16) headerp->offset[2], 4 ));
  21.     printf ("\tfirst instruction at offset\t%s\n\n",
  22.                 hexstring ( (UNS16) headerp->offset[3], 4 ));
  23.  
  24.     if (nvar)
  25.     {
  26.         puts ("Variable section dump:");
  27.         for (i = 0; i < nvar; i++)
  28.             printf ("\tvariable %s: %s\n",
  29.                     hexstring (i, 4),
  30.                     varname (var [i].type));
  31.         putchar ('\n');
  32.     }
  33.  
  34.     if (headerp->offset[0] < headerp->offset[1])
  35.     {
  36.         oldoffs = ftell (infile);
  37.         puts ("String constants dump:");
  38.         fseek (infile, headerp->offset[0], SEEK_SET);
  39.         while (ftell (infile) < headerp->offset[1])
  40.         {
  41.             fgetz (buf, 199, infile);
  42.             printf ("\t\"");
  43.             dumpstring (buf);
  44.             printf ("\"\n");
  45.         }
  46.         putchar ('\n');
  47.         fseek (infile, oldoffs, SEEK_SET);
  48.     }
  49.  
  50.     puts ("Disassembled code:");
  51.     while ( (curoffs = (UNS16) ftell (infile)) < (UNS16) headerp->offset[0] )
  52.     {
  53.         if ( (op = getopcode (infile)) < op_hlt &&
  54.              op != -1
  55.            )
  56.         {
  57.             printf ("\t[%s] ", hexstring (curoffs, 4));
  58.             printf ("%s ", hexstring (op, 2));
  59.             procfun [op] ();
  60.         }
  61.         else
  62.         {
  63.             fprintf (stderr, "bad opcode at %s", hexstring (curoffs, 4));
  64.             error ("(opcode %s)", hexstring (op, 2));
  65.         }
  66.     }
  67.     putchar ('\n');
  68. }
  69.